﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>接口测试</title>
    <script src="https://apps.bdimg.com/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
    <script src="pdm.layout.js" type="text/javascript"></script>
	
</head>
<body>
    <div>
        <h4>获取排版内容</h4>
        <table>
            <tr>
                <td>
                    <label>KEY：</label><input type="text" value="Xd63Eyu" id="txt_key" />
                </td>
                <td>
                    <input type="button" value="查询" id="bnt_get_key" />
                </td>
            </tr>
            <tr>
                <td class="key_result"></td>
            </tr>
        </table>
    </div>
    <div>
        <h4>上传图片</h4>
        <table>
			<tr>
				<input type="file" id="myphoto" />
				<div style="display:none" id="div_div1">
					<img src="#" id="img_myphoto" />
				</div>
			</tr>

            <tr>
                <td class="image_result"></td>
            </tr>
        </table>
    </div>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#bnt_get_key").bind("click", function () {
				var getkey=$("#txt_key").val();
                $.ajax({
                    type: 'POST',
                    url: ZLM.API.Data,
                    dataType: 'json',
                    data: {
                        action: 'read', //action为固定的'read'
                        key: getkey,
                    },
                    success: function (data) {
                        $(".key_result").html(JSON.stringify(data));
                    }
                });
            })
			
        })

    </script>
<script type="text/javascript">
    $("#myphoto").change(function () {
        var file = this.files[0];
        var formData = new FormData();
        formData.append('file', file);
		formData.append('action', 'upload');
		formData.append('key', 'Xd63Eyu');
		formData.append('type', 'slider');
        jQuery.support.cors = true;
        $.ajax({
            type: "POST", // 必须用post
            url: ZLM.API.Image,
            crossDomain: true,
            data: formData,
			dataType: 'json',
            contentType: false,
            processData: false,
            success: function (data) {
				$(".image_result").html(JSON.stringify(data));
            },
            error: function (res) {
                alert('出错');
            }
        });
    });
</script>
</body>
</html>
